package com.zhongying.jf;

import org.apache.commons.lang.StringUtils;

import java.math.BigDecimal;
import java.util.regex.Pattern;

public class Constant {

    //公共

    //framework
    public static final String secret = "9309314094d64d28a2aa632ece308eff";  //app secret
    public static final String HTTP_URL_HAOLI = "www.haolyy.com";  //app secret
    public static final String PLATFORM_SUB_ACCOUNT = "MDT000001";  //app secret
    /*** swagger开关*/
    public static final String SWAGGER_SWITCH_ON = "on";
    public static String PLATFROM_HLW = "HLW";
    public static String PLATFROM_ZZT = "ZZT";
    public static String PLATFROM_HKF = "HKF";

    //zhongying-api
    public static final String REPAY_REQUEST = "repay_request";  //app secret

    //common

    //userManage
    public static String DUANXIN = "duanxin";
    public static String LOGIN_TIMES_KEY = "LOGIN_TIMES_KEY";//登录次数缓存key后缀
    public static String PHONE_PWD_ERROR_TIMES_KEY = "PHONE_PWD_ERROR_TIMES_KEY";//手机输入错误次数
    public static Integer MAX_LOGIN_TIMES = 7;//最大登录次数
    public final static long MIN_INTERVAL_TIME = 1000;
    public final static String USER_NOT_LOCKED_STATUS = "1";//用户未锁定状态
    public final static String USER_LOCKED_STATUS = "2";//用户锁定状态
    public static Pattern pwdReg = Pattern.compile("^(?!^\\d+$)(?!^[a-zA-Z]+$)(?!^_+$)[\\d|a-zA-Z|_]{8,16}$");
    //    private Pattern numReg = Pattern.compile("^((13[0-9])|(15[^4])|(18[0-9])|(17[0-3,5-8])|(14[5,7,9]))\\d{8}$");
    public static Pattern numReg = Pattern.compile("^1\\d{10}$");
    public static Pattern imageReg = Pattern.compile("^[a-zA-Z0-9]{4}");
    public static Pattern smsReg = Pattern.compile("\\d{6}$");
    //    private Pattern inviteReg = Pattern.compile("([0-9](?=[0-9]*?[a-zA-Z])\\w{5})|([a-zA-Z](?=[a-zA-Z]*?[0-9])\\w{5})");
    public static Pattern inviteReg = Pattern.compile("^1\\d{10}$");
    public static Pattern nameReg = Pattern.compile("^[\\u4E00-\\u9FA5]+$");
    public static Pattern idCardReg = Pattern.compile("(^\\d{15}$)|(^\\d{17}(\\d|X)$)");

    public static final  String USER_OPEN_ACCOUNT = "KH-";//用户开户订单
    public static final  String USER_RECHARGE = "";//用户充值订单
    public static final  String USER_CASH = "UMC";//用户取现订单
    public static final  String USER_BOS_ACTIVATE = "UBA";//用户激活
    //product-from
    public static final String BORROW_BEI_AN = "BBA";//标的备案
    //product-sale
    public static final String PRODUCT_BUY_ORDER = "PSI";//主动投标业务订单号
    public static final String EVENT_BUY_ORDER = "PSE";//主动投标事件订单号
    /*** 转账类型 1:还款 2:补偿 3:补差 4:超额收益 5:返现券返现*/
    public static final Integer TRANSFER_TYPE_1 = 1;

    //product-plan
    public static final  String AUOTO_COMPENSATION_ORDER = "ACO";//自动代偿订单号

    public static final Integer BORROW_STATUS_NOT_START = 3;//未开始
    public static final Integer BORROW_STATUS_STARTED = 4;//开始募集
    public static final Integer BORROW_STATUS_FULL = 5;//已满标
    public static final Integer BORROW_STATUS_INTEREST = 7;//计息中
    public static final Integer BORROW_STATUS_END = 9;//已结束
    public static final Integer BORROW_STATUS_FLOW = 10;//流标
    public static final Integer BORROW_STATUS_PART_FULL = 11;//部分满标

    public static final String REPAY_TYPE_IS_SETTLE = "1";//是否结清：1是 2否
    public static final String REPAY_TYPE_NORMAL = "2";

    public static final Integer REPAY_STATUS_ING = 1;//回款中
    public static final Integer REPAY_STATUS_EARLY_SETTLE = 2;//提前结清
    public static final Integer REPAY_STATUS_IS_SETTLE = 3;//已结清
    public static final Integer REPAY_STATUS_IS_CANCEL = 4;//已作废

    public static final Integer BILL_INVEST_DETAIL_STATUS_NOT_DUE = 1;//未到期
    public static final Integer BILL_INVEST_DETAIL_STATUS_REPAY_PART = 2;//部分还款
    public static final Integer BILL_INVEST_DETAIL_STATUS_EARLY_SETTLE = 3;//提前结清
    public static final Integer BILL_INVEST_DETAIL_STATUS_IS_SETTLE_FROZEN = 4;//已结清待解冻
    public static final Integer BILL_INVEST_DETAIL_STATUS_IS_SETTLE = 5;//已结清

    public static final String REPAY_PLAN_STATUS = "repay_plan_status";//还款状态（redis key）

    public static final Integer STATUS_PENDING_EXECUTION = 1;//待执行
    public static final Integer STATUS_EXECUTE_SUCCESS = 2;//执行成功
    public static final Integer STATUS_EXECUTE_FAIL = 3;//执行失败
    public static final Integer STATUS_EXECUTE_ING = 4;//执行处理中
    public static final Integer STATUS_EXECUTE_EXCEPTION = 5;//执行异常

    public static final Integer DZ_STATUS_COMPENSATORY_NOT = 1;//未代偿
    public static final Integer DZ_STATUS_COMPENSATORY_ALL = 2;//全部代偿
    public static final Integer DZ_STATUS_COMPENSATORY_ING = 3;//代偿中
    public static final Integer DZ_STATUS_COMPENSATORY_FAIL = 4;//代偿失败
    public static final Integer DZ_STATUS_COMPENSATORY_PART = 5;//部分代偿
    public static final Integer DZ_STATUS_COMPENSATORY_CLEAR = 6;//代偿已还清


    //order
    public static final String MODEL_TYPE_API = "1";//zhongying-api
    public static final String MODEL_TYPE_USERMANAGE = "2";//userManage
    public static final String MODEL_TYPE_ACCOUNTMANAGE = "3";//accountManage
    public static final String MODEL_TYPE_BANK = "4";//bank
    public static final String MODEL_TYPE_COMMENT = "5";//common
    public static final String MODEL_TYPE_PRODUCTFROM = "6";//product_from
    public static final String MODEL_TYPE_PRODUCTSALE = "7";//product_sale
    public static final String MODEL_TYPE_PRODUCTPLAN = "8";//product_plan

    //accountManage
    /** 用户账户LOG日志表TYPE常量 */
    public static final int ACCOUNT_LOG_TYPE_2001 = 2001;//充值
    public static final int ACCOUNT_LOG_TYPE_200101 = 200101;//充值佣金
    public static final int ACCOUNT_LOG_TYPE_200102 = 200102;//充值手续费
    public static final int ACCOUNT_LOG_TYPE_200301 = 200301;//提现冻结
    public static final int ACCOUNT_LOG_TYPE_200302 = 200302;//提现解冻
    public static final int ACCOUNT_LOG_TYPE_200303 = 200303;//提现扣除
    public static final int ACCOUNT_LOG_TYPE_200304 = 200304;//提现手续费
    public static final int ACCOUNT_LOG_TYPE_200305 = 200305;//提现手续费回退
    public static final int ACCOUNT_LOG_TYPE_200306 = 200306;//提现佣金
    public static final int ACCOUNT_LOG_TYPE_200307 = 200307;//待提现金额
    public static final int ACCOUNT_LOG_TYPE_200308 = 200308;//待提现手续费金额
    public static final int ACCOUNT_LOG_TYPE_3013 = 3013;//资金冻结
    public static final int ACCOUNT_LOG_TYPE_3014 = 3014;//资金解冻
    public static final int ACCOUNT_LOG_TYPE_30031 = 30031;//投标冻结
    public static final int ACCOUNT_LOG_TYPE_300600 = 300600;//投标解冻
    public static final int ACCOUNT_LOG_TYPE_30032 = 30032;//还款冻结
    public static final int ACCOUNT_LOG_TYPE_300601 = 300601;//还款解冻
    public static final int ACCOUNT_LOG_TYPE_30033 = 30033;//债权认购冻结
    public static final int ACCOUNT_LOG_TYPE_300602 = 300602;//债权认购解冻
    public static final int ACCOUNT_LOG_TYPE_30034 = 30034;//代偿冻结
    public static final int ACCOUNT_LOG_TYPE_300603 = 300603;//代偿解冻
    public static final int ACCOUNT_LOG_TYPE_300604 = 300604;//借款
    public static final int ACCOUNT_LOG_TYPE_300605 = 300605;//本金回款
    public static final int ACCOUNT_LOG_TYPE_300606 = 300606;//利息回款
    public static final int ACCOUNT_LOG_TYPE_300607 = 300607;//罚息退回
    public static final int ACCOUNT_LOG_TYPE_300608 = 300608;//还派息款
    public static final int ACCOUNT_LOG_TYPE_300609 = 300609;//贷后管理费
    public static final int ACCOUNT_LOG_TYPE_300610 = 300610;//罚息
    public static final int ACCOUNT_LOG_TYPE_300611 = 300611;//投标扣除
    public static final int ACCOUNT_LOG_TYPE_300612 = 300612;//还款扣除
    public static final int ACCOUNT_LOG_TYPE_300613 = 300613;//债权认购扣除
    public static final int ACCOUNT_LOG_TYPE_300614 = 300614;//代偿扣除
    public static final int ACCOUNT_LOG_TYPE_300615 = 300615;//分润
    public static final int ACCOUNT_LOG_TYPE_300617 = 300617;//平台服务费
    public static final int ACCOUNT_LOG_TYPE_300618 = 300618;//收益补差
    public static final int ACCOUNT_LOG_TYPE_300624 = 300624;//还代偿款
    public static final int ACCOUNT_LOG_TYPE_300625 = 300625;//派息
    public static final int ACCOUNT_LOG_TYPE_300626 = 300626;//代充值（此类型为平台账户记账使用）
    public static final int ACCOUNT_LOG_TYPE_300627 = 300627;//平台资金划拨
    public static final int ACCOUNT_LOG_TYPE_30041 = 30041;//取消投标冻结
    public static final int ACCOUNT_LOG_TYPE_30042 = 30042;//取消还款冻结
    public static final int ACCOUNT_LOG_TYPE_30043 = 30043;//取消债权认购冻结
    public static final int ACCOUNT_LOG_TYPE_30044 = 30044;//取消代偿冻结
    public static final int ACCOUNT_LOG_TYPE_30101 = 30101;//授权投标冻结
    public static final int ACCOUNT_LOG_TYPE_30102 = 30102;//授权还款冻结
    public static final int ACCOUNT_LOG_TYPE_30103 = 30103;//授权债权认购冻结
    public static final int ACCOUNT_LOG_TYPE_30104 = 30104;//授权代偿冻结
    public static final int ACCOUNT_LOG_TYPE_300628 = 300628;//平台调整
    public static final int ACCOUNT_LOG_TYPE_300629 = 300629;//银行调整
    public static final int ACCOUNT_LOG_TYPE_300630 = 300630;//履约保证金
    public static final int ACCOUNT_LOG_TYPE_300631 = 300631;//风险缓释金
    public static final int ACCOUNT_LOG_TYPE_300632 = 300632;//风险计提金
    public static final int ACCOUNT_LOG_TYPE_300633 = 300633;//存钱罐收益
    public static final int ACCOUNT_LOG_TYPE_3006 = 3006;//活动返现
    public static final int ACCOUNT_LOG_TYPE_30045 = 30045;//还款转账冻结（冻结不可用）
    public static final int ACCOUNT_LOG_TYPE_30046 = 30046;//还款转账
    public static final int ACCOUNT_LOG_TYPE_300616 = 300616;//还款扣除（冻结不可用）

    public static final int ACCOUNT_LOG_TYPE_330003 = 330003;//平台商户号代充值
    public static final int ACCOUNT_LOG_TYPE_330005 = 330005;//借款人还款本金
    public static final int ACCOUNT_LOG_TYPE_350006 = 350006;//借款人还款利息
    public static final int ACCOUNT_LOG_TYPE_330007 = 330007;//投资人本金回款
    public static final int ACCOUNT_LOG_TYPE_350007 = 350007;//投资人利息回款


    /** 用户账户LOG日志表 操作方式 */
    public static final int ACCOUNT_LOG_OPERATE_TYPE_1 = 1;//收入
    public static final int ACCOUNT_LOG_OPERATE_TYPE_2 = 2;//支出
    public static final int ACCOUNT_LOG_OPERATE_TYPE_3 = 3;//平移
    /**是否冻结*/
    public static final String ISFREEZE_Y = "Y";
    public static final String ISFREEZE_N = "N";
    /** 第三方平台标识*/
    public static final int HUI_FU = 1;
    public static final int LAN_MAO = 2;

    //还款手续费
    public static final BigDecimal REPAY_FEE = new BigDecimal("0.00");

    /** 对账批次表类型 */
    public static final int SLT_SETTLE_BATCH_TYPE_1 = 1;//充值对账
    public static final int SLT_SETTLE_BATCH_TYPE_2 = 2;//提现对账
    public static final int SLT_SETTLE_BATCH_TYPE_3 = 3;//商户扣款对账表
    public static final int SLT_SETTLE_BATCH_TYPE_4 = 4;//放款对账
    public static final int SLT_SETTLE_BATCH_TYPE_5 = 5;//还款对账
    public static final int SLT_SETTLE_BATCH_TYPE_6 = 6;//交易对账
    public static final int SLT_SETTLE_BATCH_TYPE_7 = 7;//客户信息更新对账
    public static final int SLT_SETTLE_BATCH_TYPE_8 = 8;//鉴权对账
    public static final int SLT_SETTLE_BATCH_TYPE_9 = 9;//用户余额对账
    public static final int ACCOUNT_ORG_TYPE_REVENUE = 3;//作业账户类型 1:普通用户 2:风险保证金账户 3:营收账户 4:分账账号 5:红包账户 6:运营账户

    public static final int ACCOUNT_ORG_STATUS_USABLE = 1;//是否可用 1:可用 2:不可用 3:冻结

    //清结算对账明细ID
    public static final  String QJS_DZ_RECHARGE = "QDR";  //充值对账
    public static final  String QJS_DZ_CASH = "QDC";  //取现对账
    public static final  String QJS_DZ_LOAN = "QDL";  //放款对账
    public static final  String QJS_DZ_TRF = "QDT";  //扣款对账
    public static final  String QJS_DZ_ACCOUNT_TRANSACTION = "QDA";  //交易对账
    public static final  String QJS_DZ_AUTH = "QDH";  //鉴权对账
    public static final  String QJS_DZ_USER = "QDU";  //用户信息修改对账

    public static final  String QJS_DZ_BAL= "QDB";  //用户余额对账


    public static String chineseName(String fullName) {
        if (StringUtils.isBlank(fullName)) {
            return "";
        }
        String name = StringUtils.left(fullName, 1);
        return StringUtils.rightPad(name, StringUtils.length(fullName), "*");
    }
}
